-- 匹诺曹冈布奥

function initPinocchio(self, buildingInfo, dbase, pos)
    if type(buildingInfo) ~= "table" then
        -- 没要求，配置错误
        error("获取不到匹诺曹配置！");
        return;
    end

    -- 获得匹诺曹冈布奥
    local function okFun()
        -- 尝试尝试触发
        DungeonActionM.go("slime_event", pos, 120);

        -- 建筑消失
        playBuildingDisappear(self);
    end

    -- 获得匹诺曹奖励碎片
    local function okFun2()
        -- 尝试触发事件
        DungeonActionM.go("slime_event", pos, 121);

        -- 建筑消失
        playBuildingDisappear(self);
    end

    local petId = SlimeEventM.query(120, "dbase")["pet_id"];
    -- 建筑图标
    local iconPath = getHeroIconPath(petId);

    -- 访问建筑
    local function onClicked(sender, eventType)
        if eventType == ccui.TouchEventType.ended then
            if self.gridData.state == GRID_STATE_DISABLE then
                -- 格子失效了
                return;
            end

            -- 更新建筑访问
            self:updateBuildingVisit();

            if PetM.getMyPet(petId) then
                -- 有冈布奥
                self:openBuildingView(okFun2, -20, buildingInfo["dialog2"],
                   buildingInfo["view_text2"], nil, iconPath);
            else
                -- 没有冈布奥
                self:openBuildingView(okFun, -20, buildingInfo["dialog"],
                   buildingInfo["view_text"], nil, iconPath);
            end

            AudioM.playFx("slime_adventurer_app");
        end
    end

    self.icon = ccui.ImageView:create(iconPath);
    self.icon:setTouchEnabled(true);
    self.item:addChild(self.icon);
    self.iconPath = iconPath;
    self.icon:addTouchEventListener(onClicked);
    self.icon:setScale(1.3);
    self.item:setPositionX(-5);
    self.item:setPositionY(-5);

    -- 呼吸
    self.needAnimation = true;
end

